﻿using System;

namespace EmbeddedSharp.Core.Function.Maths {

    /// <summary>
    /// Ceiling
    /// </summary>
    [Function("ceiling", "Ceiling", "a=ceiling(10.5);", "a==11")]
    public class CeilingNode : FuncNode {
        public CeilingNode()
            : base("ceiling") {
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                throw new ArgumentException(
                    "usage: ceiling(number)");
            }

            double result = Convert.ToDouble(Parameters[0].Evaluate());

            return System.Math.Ceiling(result).ToString();
        }
    }
}
